EbN0_db = 0:11;
Eb = 1;       //signal energy per bit
EbN0 = 10^(EbN0_db./10);
N0 = Eb./EbN0;         //noise energy
sigma = sqrt(N0./2);

totalBitNum = 1D7;
once = 10000;
errBitNum = zeros(SNR_db);
msgBer = zeros(SNR_db);

for j = 1:length(SNR_db)
  thisSigma = sigma(j);
  for i = 1:totalBitNum/once
    //msg is vector of length 'once', elements are -1 or 1
    msg = sign( rand(1, once, 'normal')); 
    code = msg; //no coding
    noise = thisSigma*rand(1, once, 'normal');
    rcv_code = code + noise;
    rcv_msg = sign(rcv_code);
    errBitNum(j) = errBitNum(j) + length(find(rcv_msg ~= msg));
  end
end

msgBer = errBitNum./totalBitNum
